# -*- coding: utf-8 -*-
import logging
from flask import request
from logging.handlers import RotatingFileHandler
import os
from .decorator.ext_decorator import ext_decorator
@ext_decorator
def init_logging(app):
    """
    初始化日志
    :param app:
    :return:
    """
    basedir = os.path.join(app.root_path, '..')
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')

    file_handler = RotatingFileHandler(os.path.join(basedir, 'logs/ppress.log'),
                                       maxBytes=10 * 1024 * 1024, backupCount=10,encoding='utf-8')
    file_handler.setFormatter(formatter)
    file_handler.setLevel(logging.INFO)
    app.logger.addHandler(file_handler)